home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Libraries / SAT 2.3a1 / Collision ƒ / Collision.p < prev    next >
Encoding:
Text File  |  1994-11-03  |  1.5 KB  |  63 lines  |  [TEXT/PJMM]

  1. {*****************************}
  2. {********* SAT Collision **********}
  3. {*****************************}
  4.  
  5. {A SAT demo that is slightly over SATminimal, demonstrating the simplest}
  6. {collision handling based on the kind field (KindCollision).}
  7.  
  8. program SATcollision;
  9.  
  10.     uses
  11. {$ifc UNDEFINED THINK_PASCAL}
  12.         Types, QuickDraw, Events, Windows, Dialogs,
  13.         Fonts, DiskInit,
  14.         TextEdit, Traps, Desk, Memory, SegLoad, Scrap,
  15.         ToolUtils, OSEvents, OSUtils, Menus, Resources,
  16.         StandardFile, GestaltEqu, Files, Errors,
  17. {$endc}
  18.         SAT, sMrEgghead, sApple;
  19.  
  20.     var
  21.         ignoreSp: SpritePtr;
  22.         l: longint;
  23.         p: Point;
  24. begin
  25. {Standard Inits are done by Think Pascal.}
  26. {$IFC UNDEFINED THINK_PASCAL}
  27.         InitGraf(@qd.thePort);
  28.         InitFonts;
  29.         InitWindows;
  30.         InitMenus;
  31.         TEInit;
  32.         InitDialogs(nil);
  33.         MaxApplZone;
  34. {$ENDC}
  35.  
  36. {Initialize SAT}
  37.     SATConfigure(true, kVPositionSort, kKindCollision, 32);
  38.     SATInit(128, 129, 512, 322);
  39.  
  40. {Initialize sprite units}
  41.     InitMrEgghead;
  42.     InitApple;
  43.  
  44. {Make sprites}
  45.     GetMouse(p); {We get the mouse position in order to put Mr Egghead under it immediately}
  46.     ignoreSp := SATNewSprite(0, p.h, p.v, @SetupMrEgghead);
  47.     ignoreSp := SATNewSprite(0, 0, Rand(gSAT.offSizeV - 32), @SetupApple);
  48.  
  49.     HideCursor;
  50.  
  51.     repeat
  52.         l := TickCount;
  53.         SATRun(true); {Run a frame of animation}
  54.         while l > TickCount - 3 do {Speed limit}
  55.             ;
  56.  
  57. {Start a new apple once in a while}
  58.         if Rand(40) = 1 then
  59.             ignoreSp := SATNewSprite(0, 0, Rand(gSAT.offSizeV - 32), @SetupApple);
  60.     until Button;
  61.     ShowCursor;
  62.     SATSoundShutUp; {Always make sure the sound channel is de-allocated!}
  63. end.